package com.shop.shoppingmall.service.impl;

import com.shop.shoppingmall.dao.ShProductSpecsDao;
import com.shop.shoppingmall.entity.ShProductSpecs;
import com.shop.shoppingmall.service.ShProductSpecsService;
import com.shop.shoppingmall.util.api.vo.Result;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * (ShProductSpecs)表服务实现类
 *
 * @author makejava
 * @since 2020-09-07 17:09:48
 */
@Service("shProductSpecsService")
@Transactional
public class ShProductSpecsServiceImpl implements ShProductSpecsService {
    @Resource
    private ShProductSpecsDao shProductSpecsDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public ShProductSpecs queryById(String id) {
        return this.shProductSpecsDao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<ShProductSpecs> queryAllByLimit(int offset, int limit) {
        return this.shProductSpecsDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param shProductSpecs 实例对象
     * @return 实例对象
     */
    @Override
    public ShProductSpecs insert(ShProductSpecs shProductSpecs) {
        this.shProductSpecsDao.insert(shProductSpecs);
        return shProductSpecs;
    }

    /**
     * 修改数据
     *
     * @param shProductSpecs 实例对象
     * @return 实例对象
     */
    @Override
    public Result update(ShProductSpecs shProductSpecs) {
        shProductSpecsDao.update(shProductSpecs);
        return Result.ok("修改成功");
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(String id) {
        return this.shProductSpecsDao.deleteById(id) > 0;
    }
}